<template>
  <div :style="`height:${height}; overflow-y:auto`">
    <ul class="icon-list">
      <li v-for="(icon, i) in icons" :key="i" :class="icon == selectIcon ? 'selected' : ''">
        <a :class="icon" @click="iconClick(icon)" :title="icon"></a>
      </li>
    </ul>
  </div>
</template>
<script>
export default {
  name: "mf-icon-list",
  model: {
    prop: "value",
    event: "iconSelected"
  },
  props: {
    value: {
      type: String,
      default: ""
    },
    height: {
      type: String,
      default: '400px'
    }
  },
  computed: {
    icons() {
      return this.$minifox.icons;
    },
    selectIcon: {
      get() {
        return this.value;
      },
      set(val) {

        this.$emit('iconSelected', val);
      }
    }
  },
  data() {
    return {
    }
  },
  methods: {
    iconClick(iconName) {
      this.selectIcon = iconName;
      // this.selected = iconName;
      // this.$emit('iconSelected', iconName);
    }
  }
}
</script>
<style scoped>
.icon-list {
  list-style: none;
  padding: 2px;
  display: flex;
  flex-wrap: wrap;
}

.icon-list li {
  float: left;
  padding: 5px;
}

.icon-list li a {
  display: block;
  width: 30px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  color: #222222;
  cursor: pointer;
}

.icon-list li a:hover {
  background-color: #5bc0de;
  color: #fff;
}

.icon-list .selected a {
  background-color: #075a8b;
  color: #fff;
}
</style>
